//
//  FriendListCell.m
//  OGL
//
//  Created by ZengYuan on 15/3/18.
//  Copyright (c) 2015年 ZengYuan. All rights reserved.
//

#import "UserCell.h"
#import "Config.h"
@implementation UserCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *ID = @"UserCellID";
    UserCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (cell == nil) {
        cell = [[UserCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    
    return  cell;
}


-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    CGRect rec = self.frame;
    rec.size.width=kScreenWidth;
    self.frame=rec;
    
    self.photoImgView =[[UIImageView alloc]init];
    self.photoImgView.contentMode = UIViewContentModeScaleAspectFill;
    self.photoImgView.clipsToBounds=YES;
    [self addSubview:self.photoImgView];

    self.photoImgView.layer.cornerRadius = 20;
    self.photoImgView.layer.masksToBounds=YES;
    
    [self.photoImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(20);
        make.centerY.equalTo(self);
        make.height.equalTo(@40);
        make.width.equalTo(@40);

     }];
    

    
    
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.textColor = MAIN_TEXT_COLOR;
    [self addSubview:self.nameLabel];
    self.nameLabel.font = [UIFont systemFontOfSize:15];
    
    [self.nameLabel  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(KFRIENDCELL_NAME_OFFSETX);
        make.centerY.equalTo(self);
        make.width.equalTo(@200);
        make.height.equalTo(@21);
     }];
    

    self.detailLabel = [[UILabel alloc]initWithFrame:CGRectMake(KFRIENDCELL_NAME_OFFSETX, 31, 200, 21)];
    self.detailLabel.font = [UIFont systemFontOfSize:13];
    self.detailLabel.textColor=[UIColor grayColor];
    [self addSubview:self.detailLabel];
    
    
//    HorizonLine *line = [[HorizonLine alloc]init];
//    [self addSubview:line];
//    [line setLineColor:LINE_COLOR];
//    
//    [line mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.mas_left).offset(0);
//        make.right.equalTo(self.mas_right).offset(0);
//        make.width.equalTo(self.mas_width);
//        make.height.equalTo(@1);
//        make.bottom.equalTo(self.mas_bottom).offset(0);
//    }];
//    
    self.tipBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.tipBtn setBackgroundImage:[UIImage imageNamed:@"little_green"] forState:UIControlStateNormal];
    self.tipBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    self.tipBtn.titleLabel.textColor=[UIColor whiteColor];
    self.tipBtn.tag=100;
    [self addSubview:self.tipBtn];
    
    
    [self.tipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self.mas_right).offset(-20);
        make.width.equalTo(@60);
        make.height.equalTo(@30);
    }];
    self.tipBtn.hidden=YES;
    [self.tipBtn addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];

    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return self;

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


//-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
//{
//    [super setHighlighted:highlighted animated:animated];
//
//    if (highlighted)
//    {
//        self.backgroundColor = RGB(240, 240, 240);
//    }else
//    {
//        self.backgroundColor = [UIColor whiteColor];
//    }
//}


@end
